home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / xmouse11.zip / XMOUSE.DOC < prev    next >
Text File  |  1992-05-07  |  9KB  |  198 lines

  1.                       ***** Mike Duffy's Xmouse routines *****
  2.                             released April 28,1992
  3.                                   Version 1.1
  4.  
  5. I threw these routines together rather quickly, so if you find any
  6. bugs please let me know.
  7.  
  8. My Internet address is mduffy@aludra.usc.edu if you need to contact
  9. me.
  10.  
  11.                            So, What exactly is this?
  12.  
  13.       These routines work in the VGA graphics mode ModeX as put
  14. forth in the July 1991 issue of "Dr. Dobbs Journal" by Michael
  15. Abrash.  The routines that set up the mode, draw a pixel, and draw
  16. a filled rectangle as included in the MXLIB.OBJ file are pretty
  17. much taken from the articles in DDJ with few changes.  The source
  18. code is available in archives handling code from DDJ.  Try
  19. anonymous ftp from SIMTEL20.ARMY.MIL in their mirrors directory.
  20. Seek and ye shall find.
  21.       As far as the mouse routines, I wrote those suckers.  They are
  22. designed to create a mouse cursor for you since most mouse drivers
  23. do not handle the undocumented ModeX.
  24.  
  25.                                Da Instructions:
  26.  
  27.       Ok, the following is a description of each of the various
  28. routines available.
  29.  
  30.                  unsigned int minitialize(unsigned int MouseX,
  31.                              unsigned int MouseY,
  32.                              unsigned char Color);
  33.  
  34.       This is called to check if the mouse is there, initialize it,
  35. and set up various variables.  MouseX and MouseY are the starting
  36. coordinates of the mouse on the screen, and Color is the color of
  37. the mouse cursor.  For simplicity, the mouse is only one color.
  38. The routine will return a 1 if everything is fine and a 0 if a
  39. mouse is not installed (i.e. no mouse driver).  The global variable
  40. "mpresent" is set to 1 if a mouse is present and 0 otherwise.
  41.  
  42.                              void muninitialize();
  43.  
  44.       This should be called at the end of your program when you are
  45. done with the mouse.  It releases the interrupt vectors the
  46. initialize routine set up.  
  47.  
  48.                             void mshowcursor(void);
  49.  
  50.       This routine tells the driver to make the mouse cursor
  51. visible.  While the mouse cursor is visible, the global variables
  52. "mousex" and "mousey" contain the current x and y coordinates of
  53. the mouse cursor.  These variables are not updated when the cursor
  54. is hidden because it is rather silly to use an invisible cursor.
  55.  
  56.                             void mhidecursor(void);
  57.  
  58.       This routine hides the cursor from view.  Hence its name.
  59.  
  60.                        void setmlimits(unsigned int x1,
  61.                                unsigned int y1,
  62.                                unsigned int x2,
  63.                                unsigned int y2);
  64.  
  65.       This routine allow you to set the maximum and the minimum x
  66. and y coordinates that the mouse can travel, thus allowing you to
  67. restrict it to a certain rectangle on the screen.  The values for
  68. x1 and x2 can go from 0 to 319 and the y1 and y2 values can go from
  69. 0 to 239.  The top left corner of this rectangle is defined by
  70. (x1,y1) and the lower right corner is defined by (x2,y2).  Mix them
  71. up and your computer will probably take on a life of its own, grab
  72. the nearest piece of heavy furniture, and beat you into a small
  73. lifeless pile of muck.
  74.  
  75.  
  76.  
  77.                          unsigned int mnonepresssed();
  78.                          unsigned int mleftpressed();
  79.                          unsigned int mrightpressed();
  80.                          unsigned int mbothpressed();
  81.                         unsigned int mcenterpressed();
  82.                       unsigned int mcenterleftpressed();
  83.                       unsigned int mcenterrightpressed();
  84.                           unsigned int mallpressed();
  85.  
  86.       This set of routines lets you find out the state of your mouse
  87. buttons.  They return a 1 if the button is pressed and a 0 if not. 
  88. Both means left and right button and all means all three buttons
  89. (that is of course, if you have a three button mouse.)  You ought
  90. to be able to figure out which routine does what, and if you can't
  91. then you probably shouldn't be programming anyway.
  92.  
  93.  
  94.                    void setcursshape(enum curstype thetype);
  95.  
  96.       This is a neat feature of the Xmouse driver.  You can change
  97. the shape of the cursor by placing the name of the cursor you want
  98. in the variable passed to the routine.  The following are the
  99. cursors available:
  100.  
  101. Standard, UpArrow, LeftArrow, CheckMark, PointingHand,
  102. DiagonalCross, RectangularCross, HourGlass, UserDef1, UserDef2,
  103. UserDef3, UserDef4
  104.  
  105. The last four, the UserDef selections, can be defined by the user. 
  106. The format for the cursor information is a bitmap 8 bits wide by
  107. 8 rows high.  This is stored in an array of 8 unsigned chars.  This
  108. bitmap is a bit unique in that you have to draw your cursor
  109. backwards to get it to display forwards (VGA registers are screwy,
  110. aren't they?)  For example the bitmap for the standard cursor is:
  111.  
  112.  00111111      The '1's are colored in and the '0's are masked out.
  113.  00011111      figure the value out for each row as if each row
  114.  00001111      were a binary value (because by golly, they ARE
  115.  00011111      binary values!)
  116.  00111011
  117.  01110001      <---- This line represents the value 113. 
  118.  11100000          If you don't know binary.... learn it!
  119.  11000000
  120.  
  121. Also included in the definition of a mouse cursor is a hot spot. 
  122. The hot spot is the pixel that is considered the mouse's
  123. coordinate.  On the cursor above, it is at the tip of the arrow and
  124. has a value of HorizHotSpot = 0 and VertHotSpot = 0.  This is the
  125. upper right corner of the bitmap above, but since it will be
  126. flipped left to right when displayed, the hot spot will be the
  127. upper left corner.  The value of the hot spot can go from 0 to 7,
  128. and dat's it.  To make things easier I type set them as a
  129. structure.  The variables are UserDefCurs1, UserDefCurs2,
  130. UserDefCurs3, UserDefCurs4.  Shouldn't be too hard to figure out.
  131.  
  132.  
  133.  
  134.                               Da Technical Stuff:
  135.  
  136.       First off, the driver needs the last 97 bytes in the display
  137. memory segment (i.e. segment 0xa000).  Don't mess with them.
  138.  
  139.       Secondly, the driver attaches into the standard mouse driver
  140. via mouse interrupt function 0C hex.  Don't mess with this either.
  141. The uninitialize function releases the interrupt vector set up with
  142. this function so that everything is nice and clean.
  143.  
  144.       As far as memory models go, the Xmouse will work on tiny,
  145. small, compact, medium, and large memory models.  Just include the
  146. correct object file in your project (tiny = TXMOUSE.OBJ,
  147. small = SXMOUSE.OBJ, and medium = MXMOUSE.OBJ).  Xmouse take up 146
  148. bytes out of your data segment.  If you need other memory models to
  149. be supported and you beg and plead, then I MIGHT consider altering
  150. my source code and recompiling, my schedule permitting.  Try the
  151. medium memory model first though; it's a good one.
  152.  
  153.  
  154.                                    Licencing
  155.  
  156.       The object code for these routines is hereby released to the
  157. public (i.e. they are public domain).  In exception to the above
  158. sentence are the routines drawn from the Michael Abrash articles
  159. in Dr. Dobb's Journal, July 1991, August 1991, and September 1991
  160. issues.
  161.  
  162.       The routines based on routines in Michael Abrash's articles
  163. are as follows, with the names of Abrash's routine in parenthasis
  164. setmodex() (a variant of Set320x240Mode()), xputpix() (WritePixelX()),
  165. xgetpix() (ReadPixelX()), xbar() (FillRectangleX()), and showpage()
  166. (ShowPage()).  The rest of the routines are hereby public domain.
  167.  
  168.       Furthermore, the user shall use these routines at his own
  169. risk.  The author is not responsible for any damages to computer,
  170. projects, programs, time, scheduling, hardware, software, loss of
  171. hair, sanity, or sleep due to correct or incorrect use of the
  172. routines.  In other words ....
  173.  
  174.       Don't blame me for problems.... I'm not responsible.
  175.  
  176.                                   Mike Duffy
  177.                             (mduffy@aludra.usc.edu)
  178.  
  179.  
  180. /***********************************************/
  181.  
  182. Release History (as if you cared):
  183.  
  184. Ver 1.0 April 28, 1992
  185.         The basic package released to the hungry public.
  186.  
  187. Ver 1.1 May 7, 1992
  188.         I fixed a couple of bugs in the mshowcursor and mhidecursor routines.
  189.         Compact and Large memory models now supported.
  190.         A few of the routines in the xlib package were renamed.  Sorry for the
  191.         inconvenience (just use search and replace to fix yer programs).
  192.         Finally, the order of variables in a few of the routines were changed
  193.         so that the color would always be the last variable, instead of the
  194.     page to draw to.
  195.     The mouse cursor can now be shown on any of the pages in display
  196.     memory.
  197.     A showpage() routine has been added to xlib.
  198.